package me.stephenj.experiment2.mapper;

import me.stephenj.experiment2.model.Mail;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

/**
 * @Title MailMapper.java
 * @Description MailMapper类
 * @author 张润天
 * @Time 2020/4/21 12:29
 * @version v0.01
 */

@Component
public interface MailMapper {

    /**
     * @Title Method
     * @Description 找到最大编号
     */
    @Select("SELECT MAX(`ID`) FROM Mail")
    int max();

    /**
     * @Title Method
     * @Description 使用邮箱地址编号查找信息
     */
    @Select("SELECT * FROM Mail WHERE ID=#{ID}")
    Mail getMail(int ID);

    /**
     * @Title Method
     * @Description 添加邮箱地址
     */
    @Insert("INSERT INTO `Mail` (`ID`, `Name`, `Address`) VALUE (#{ID}, #{Name}, #{Address})")
    int insert(Mail mail);

    /**
     * @Title Method
     * @Description 修改邮箱地址信息
     */
    @Update("UPDATE `Mail` SET `Name`=#{Name}, `Address`=#{Address} WHERE `ID`=#{ID}")
    int update(Mail mail);

    /**
     * @Title Method
     * @Description 删除邮箱地址
     */
    @Delete("DELETE FROM `Mail` WHERE ID=#{ID}")
    int delete(int ID);
}
